package com.sinocr.tj.dd.explore.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.sinocr.tj.dd.explore.springmvc.domain.User;
import com.sinocr.tj.dd.explore.springmvc.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {
	
	private IUserService userService;
	
	@RequestMapping("/register")
	public String register() {
		return "user/register";
	}
	@RequestMapping(method=RequestMethod.POST)
	public ModelAndView createUser(User user){
		userService.createUser(user);
		ModelAndView mav=new ModelAndView();
		mav.setViewName("user/createSuccess");
		mav.addObject("user",user);
		return mav;
	}
}
